import { get } from 'lodash-es';
import { h } from 'vue';
import { RouterView } from 'vue-router';
import ConfigProvider from 'ant-design-vue/es/config-provider/index.js';
import Empty from 'ant-design-vue/es/empty/index.js';
import zhCN from 'ant-design-vue/es/locale/zh_CN.js';

export function getLocale() {
  return zhCN;
}

export function getContainer() {
  let container = get(window.__GLOBAL_VUE_APP, '_container');
  return container || document.getElementById('app') || document.body;
}

export function getPopupContainer(node) {
  return node && node.parentNode ? node.parentNode : getContainer();
}

export default {
  setup() {
    return () =>
      h(
        ConfigProvider,
        { locale: zhCN, getPopupContainer: getPopupContainer },
        {
          renderEmpty: () => h(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }),
          default: () => h(RouterView),
        }
      );
  },
};
